const knex = require("../db/knex")

/**
 * 重置表中id排序
 * @param my_table 表名
 * @param column_name 删除的列
 */
async function resetTableId(my_table, column_name) {
    try{
        await knex.transaction(async (trx) => {
            await knex.schema.alterTable(my_table, (table) => {//1.先删除id字段
                table.dropColumn(column_name);
            });

            await knex.schema.alterTable(my_table, (table) => {//2.新增id设为自增主键,起始值为1
                table.increments(column_name).primary().defaultTo(1);
            });
        })
    }catch (e) {

    }finally {

    }




}
module.exports = resetTableId
